<?php
// Tim'Roster
// Copyright (c) 2011 Nicolas Nallet <aspgic2@gmail.com>
//
// This file is part of Tim'Roster.
//
// Tim'Roster is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Tim'Roster is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

class Enum_Item_Class {

    const BASE_ITEM_CLASS_ID = 1;
    const BASE_ITEM_CLASS_LABEL = 'base';

    const FINE_ITEM_CLASS_ID = 2;
    const FINE_ITEM_CLASS_LABEL = 'fine';

    const CHOICE_ITEM_CLASS_ID = 3;
    const CHOICE_ITEM_CLASS_LABEL = 'choice';

    const XL_ITEM_CLASS_ID = 4;
    const XL_ITEM_CLASS_LABEL = 'xl';

    const SUP_ITEM_CLASS_ID = 5;
    const SUP_ITEM_CLASS_LABEL = 'sup';

    /**
     * (PHP 5)<br/>
     * Convert api item class code to item class id
     * @param string $value
     * @return int
     */
    public static function convert_api_code_to_id($value){

        switch ($value) {
            case 'b01':
            case 'b' :
                return Enum_Item_Class::BASE_ITEM_CLASS_ID;

            case 'c01':
            case 'f' :
                return Enum_Item_Class::FINE_ITEM_CLASS_ID;

            case 'd01':
            case 'c' :
                return Enum_Item_Class::CHOICE_ITEM_CLASS_ID;

            case 'e01':
            case 'e' :
                return Enum_Item_Class::XL_ITEM_CLASS_ID;

            case 'f01':
            case 's' :
                return Enum_Item_Class::SUP_ITEM_CLASS_ID;

            default :
                return 0;
        } //switch
    }

    /**
     * (PHP 5)<br/>
     * Convert item class id to item class label
     * @param int $value
     * @return string
     */
    public static function convert_id_to_label($value){

        switch ($value){
            case 1 :
                return Enum_Item_Class::BASE_ITEM_CLASS_LABEL;

            case 2 :
                return Enum_Item_Class::FINE_ITEM_CLASS_LABEL;

            case 3 :
                return Enum_Item_Class::CHOICE_ITEM_CLASS_LABEL;

            case 4 :
                return Enum_Item_Class::XL_ITEM_CLASS_LABEL;

            case 5 :
                return Enum_Item_Class::SUP_ITEM_CLASS_LABEL;
        }// switch

    }
}
?>
